package com.sherllinhe.${module}.controller;

import com.sherllinhe.common.resp.CommonResp;
import com.sherllinhe.common.resp.PageResp;
import com.sherllinhe.${module}.req.*;
import com.sherllinhe.${module}.resp.${Domain}QueryResp;
import com.sherllinhe.${module}.service.${Domain}Service;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 功能：
 * 作者：Sherllin He
 * 日期：
 */
@RequestMapping("/${do_main}")
@RestController
public class ${Domain}Controller {
    @Autowired
    private ${Domain}Service ${domain}Service;

    @PostMapping("/save")
    public CommonResp<Object> register(@Valid @RequestBody ${Domain}SaveReq req){
        ${domain}Service.save(req);
        return new CommonResp<>();
    }

    @GetMapping("/query-list")
    public CommonResp<PageResp<${Domain}QueryResp>> register(@Valid ${Domain}QueryReq req){
        PageResp<${Domain}QueryResp> list = ${domain}Service.queryList(req);
        return new CommonResp<>(list);
    }

    @DeleteMapping("/delete/{id}")
    public CommonResp<Object> delete(@PathVariable Long id){
        ${domain}Service.delete(id);
        return new CommonResp<>();
    }
}
